#include <iostream>
#include <cstdio>
#include <cmath>
typedef long long ll;
using namespace std;
ll a[50005];
int main() {
    int n;
    cin>>n;
    ll res=0;
    ll tmp;
    scanf("%lld", &a[0]);
    for (int i=1; i<n; i++) {
        scanf("%lld", &tmp);
        a[i]=a[i-1]+tmp;
        if (a[i]<res) res=a[i];
    }
    cout<<abs(res)<<endl;
    return 0;
}
